var config = $.extend(true, {}, listApp, {
    data: {
        service: currentdataService,
        treeData: {},
        searchVm: {
            channelCode: '',
            channelName: '',
            dataType: '',
            spotId: ''
        },
        tableVm: {
            loading: false,
            pageSize: 15
        },
        spotList: [],
        editVm: {},
        treeStyle: {
            float: 'left',
            width: '20%'
        },
        tableStyle: {
            float: 'left',
            marginLeft: '20px',
            width: '78%'
        },
        searchVm: {
            deviceId: ''
        },
        showAlarm:false,
        contentHeight: 0,
        requestPagePath: 'requestPageExt'
    },
    methods: {
        init: function () {
            let _this = this;
            //加载device列表
            spotService.getAllSpot("/getAllSpot", null, {
                success: function (ret) {
                    _this.spotList = ret;
                },
                fail: function (res) {
                    _this.showFailMsg(res.msg);
                }
            })
            this.initHeight()
        },
        initHeight: function () {
            let that = this;
            setTimeout(() => {
                let height = document.documentElement.clientHeight;
                that.contentHeight = height - 170
                // console.log("height", that.contentHeight)
            }, 200)
        },
        handleSizeChange:function (val) {
            this.tableVm.pageSize=val;
            this.search();
        },
        changeAlarm(data){
            console.log(data)
        },
        mySearch: function () {
            // console.log('==============================')
            this.treeData = {};
            this.searchVm.spotId = '';
            this.searchVm.spotParentId = '';
            this.search();
        },
        getTreeSelectedVal: function (data) {
            // console.log(data)
            this.treeData = data;
            if (!data.isDevice) {
                this.searchVm.deviceId = '';
                this.searchVm.spotId = data.id;
                this.searchVm.spotParentId = data.parentId;
            }else {
                this.searchVm.deviceId = data.id;
                this.searchVm.spotId = '';
                this.searchVm.spotParentId = '';
            }
            this.search();
        },
        collapse: function (isCollapsed) {
            if (isCollapsed) {
                this.treeStyle.width = '3%';
                this.tableStyle.width = '80%';
            } else {
                this.treeStyle.width = '20%';
                this.tableStyle.width = '78%';
            }
        },
        formatter: function (row) {
            // console.log('formatter',row);
            if(row.dataType!=null&&row.dataType!==''){
                return row.dataType == 1 ? '开关量' : '模拟量';
            }else {
                return '未设置'
            }
        }
    }
});
var app = new Vue(config);
